#ifndef LHC_ENDIAN_H_INCLUDED_
#define LHC_ENDIAN_H_INCLUDED_

#include <boost/cstdint.hpp>

namespace lhcutils
{

struct Endianness
{
	enum Value
	{
		Little,
		Big
	};
};

Endianness::Value GetHostEndianness();

boost::uint16_t FlipBytes16(boost::uint16_t int16);
boost::uint32_t FlipBytes32(boost::uint32_t int32);
boost::uint64_t FlipBytes64(boost::uint64_t int64);

boost::uint16_t LeToHost16(boost::uint16_t int16);
boost::uint16_t BeToHost16(boost::uint16_t int16);
boost::uint32_t LeToHost32(boost::uint32_t int32);
boost::uint32_t BeToHost32(boost::uint32_t int32);
boost::uint64_t LeToHost64(boost::uint64_t int64);
boost::uint64_t BeToHost64(boost::uint64_t int64);

boost::uint16_t ToHost16(boost::uint16_t int16, Endianness::Value endianness);
boost::uint32_t ToHost32(boost::uint32_t int32, Endianness::Value endianness);
boost::uint64_t ToHost64(boost::uint64_t int64, Endianness::Value endianness);

boost::uint16_t HostTo16(boost::uint16_t int16, Endianness::Value endianness);
boost::uint16_t HostToLe16(boost::uint16_t int16);
boost::uint16_t HostToBe16(boost::uint16_t int16);
boost::uint32_t HostTo32(boost::uint32_t int32, Endianness::Value endianness);
boost::uint32_t HostToLe32(boost::uint32_t int32);
boost::uint32_t HostToBe32(boost::uint32_t int32);
boost::uint64_t HostTo64(boost::uint64_t int64, Endianness::Value endianness);
boost::uint64_t HostToLe64(boost::uint64_t int64);
boost::uint64_t HostToBe64(boost::uint64_t int64);

}

#endif

/*
 Copyright 2011 Greg Najda

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
